From ed4238307a5ce6c79cf320a36c8310181193385b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 4 Sep 2018 19:09:07 +0200 Subject: [PATCH] babl-fish-reference: add lock to part of float reference This fixes problems that occur during GEGLs documentation gallery build when multiple threads are in use (the default). The critical section has experimentally been made as short as possible to avoid babl memory inconsistencies - without identifing the core race. --- babl/babl-fish-reference.c | 2 ++ babl/babl-internal.c | 3 +++ babl/babl-internal.h | 1 + tools/babl_fish_path_fitness.c | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c index 619ceb5..6d1aa84 100644 --- a/babl/babl-fish-reference.c +++ b/babl/babl-fish-reference.c @@ -900,6 +900,7 @@ babl_fish_reference_process_float (const Babl *babl, return; } + babl_mutex_lock (babl_reference_mutex); if (babl->fish.source->format.type[0] == type_float && BABL(babl->fish.source)->format.components == BABL(babl->fish.source)->format.model->components && 0) @@ -961,6 +962,7 @@ babl_fish_reference_process_float (const Babl *babl, n); } } + babl_mutex_unlock (babl_reference_mutex); if (((babl->fish.source)->format.space != ((babl->fish.destination)->format.space))) diff --git a/babl/babl-internal.c b/babl/babl-internal.c index 2f3c42e..5609720 100644 --- a/babl/babl-internal.c +++ b/babl/babl-internal.c @@ -82,6 +82,7 @@ BablMutex *babl_format_mutex; #if BABL_DEBUG_MEM BablMutex *babl_debug_mutex; #endif +BablMutex *babl_reference_mutex; void babl_internal_init (void) @@ -89,6 +90,7 @@ babl_internal_init (void) babl_set_malloc (malloc); babl_set_free (free); babl_format_mutex = babl_mutex_new (); + babl_reference_mutex = babl_mutex_new (); #if BABL_DEBUG_MEM babl_debug_mutex = babl_mutex_new (); #endif @@ -98,6 +100,7 @@ void babl_internal_destroy (void) { babl_mutex_destroy (babl_format_mutex); + babl_mutex_destroy (babl_reference_mutex); #if BABL_DEBUG_MEM babl_mutex_destroy (babl_debug_mutex); #endif diff --git a/babl/babl-internal.h b/babl/babl-internal.h index 8f31434..73fe18f 100644 --- a/babl/babl-internal.h +++ b/babl/babl-internal.h @@ -242,6 +242,7 @@ babl_fatal (const char *format, ...) extern int babl_hmpf_on_name_lookups; extern int babl_in_fish_path; extern BablMutex *babl_format_mutex; +extern BablMutex *babl_reference_mutex; #define BABL_DEBUG_MEM 0 #if BABL_DEBUG_MEM diff --git a/tools/babl_fish_path_fitness.c b/tools/babl_fish_path_fitness.c index ffd81ab..92c5935 100644 --- a/tools/babl_fish_path_fitness.c +++ b/tools/babl_fish_path_fitness.c @@ -56,7 +56,7 @@ static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"}; */ -#define NUM_TEST_PIXELS (1024*16) +#define NUM_TEST_PIXELS (1024*1024) static float test_pixels_float[NUM_TEST_PIXELS*4]; static char test_pixels_in[NUM_TEST_PIXELS * 6 * 8]; static char test_pixels_out[NUM_TEST_PIXELS * 6 * 8]; -- 2.30.2